<?php 
class Gt_Pos_Block_Adminhtml_Order_Productgrid_Renderer_Addproduct extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{   /**
     * Renders grid column
     *
     * @param   Varien_Object $row
     * @return  string
     */
    public function render(Varien_Object $row)
    {        
        //javascript:selectProduct(17,'BlackBerry 8100 Pearl', 349.99, 0.0000, 349.99, 'http://demo.boostmyshop.com/demo1/skin/adminhtml/default/default/images/OrderWizardCreation/','$')
		
		$currentProduct = Mage::getModel('catalog/product')->load($this->_getValue($row));
		if($currentProduct->getSmallImage() != null && $currentProduct->getSmallImage() != "no_selection")
			$productImage = $this->helper('catalog/image')->init($currentProduct, 'small_image')->resize(135);
		else
			$productImage = "";
		
		$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($currentProduct);
		
		if($stock->getQty() > 0){
			// Get the product's tax class' ID
			//$taxClassId = $currentProduct->getData("tax_class_id");
			// Get the tax rates of each tax class in an associative array
			//$taxClasses = $this->helper("core")->jsonDecode( $this->helper("tax")->getAllRatesByProductClass() );
			// Extract the tax rate from the array
			//$taxRate = $taxClasses["value_" . $taxClassId];
			
			// if($taxRate == null)
				// $taxRate = 0;
			
			$Finalprice = $currentProduct->getFinalPrice();	
			
			// $priceIncTax = floatval($priceExcTax) + floatval($priceExcTax) * floatval($taxRate) / 100;
			
			$html = '<a id="click_chose_product_'.$currentProduct->getId().'" class="click_chose_product" href="javascript:void(0);" onclick="javascript:selectProduct('.$currentProduct->getId().',\''.$currentProduct->getName().'\',\''.$currentProduct->getSKU().'\',\''.$productImage.'\','.$Finalprice.',\''.$this->getSkinUrl('images/gt_pos/').'\')"><img src="'.$this->getSkinUrl('images/gt_pos/add.png').'"/></a><div id="all_tier" class="price_'.$currentProduct->getId().'">';
			
			$tierprice = $currentProduct['tier_price'];
			if(count($tierprice)>0){
				$abc = 1;		
				foreach ($tierprice as $val) {
					foreach($val as $key=>$value ){
						if($key == 'price') {
							$html = $html.'<input type="hidden" id="tierp_'.$abc.'" class="col_tier_price_'.$currentProduct->getId().'" value="'.$value.'" />';
						} elseif ($key == 'price_qty') {
							$html = $html.'<input type="hidden" id="tiern_'.$abc.'" class="col_tier_price_'.$currentProduct->getId().'" value="'.$value.'" />';
						}					
					}
					$abc++;
				}
			}
			$html = $html."</div>";
		}else{
			$html = "Out Of Stock";
		}
		
		return $html;
    }
}

?> 